import request from '@/utils/request'
// 注册接口
export const userRegisterService = ({ username, password, repassword }) => {
  return request.post('api/user/reg', { username, password, repassword })
}
// 登录接口
export const userLoginService = (data) => {
  return request.post('api/user/login', data)
}

// 注册接口
export const userRegService = (data) => {
  return request.post('api/user/reg', data)
}

// 退出登录接口
export const userExitService = () => {
  return request.post('api/user/exit')
}

// 获取邮箱验证码
export const userGenerateEmailCodeService = ({ email }) => {
  return request.get('api/user/generate-email-code', {
    params: {
      email
    }
  })
}

// 测试接口
export const test = () => {
  return request.get('api/user/list')
}

// 判断用户是否拥有脚本权限
export const userIsCsdnScriptService = () => {
  return request.get('api/user/is-csdn-script')
}

// 获取用户的csdncookie
export const userGetCsdnCookieService = () => {
  return request.get('api/user/get-csdn-cookie')
}

// 设置用户的csdncookie
export const userSetCsdnCookieService = ({ cookie }) => {
  return request.post('api/user/set-csdn-cookie', { cookie: cookie })
}

// 获取用户cookie的状态
export const userGetCsdnCookieStateService = () => {
  return request.get('api/user/get-csdn-cookie-state')
}

// 设置他人评论自己博客的内容
export const userSetOtherCommentToMeService = (data) => {
  return request.post('api/user/set-other-comment-to-me', data)
}

// 设置回复评论区的内容
export const userSetReplyCommentToOtherService = (data) => {
  return request.post('api/user/set-reply-comment-to-other', data)
}

// 获取他人评论自己博客的内容
export const userGetOtherCommentToMeService = () => {
  return request.get('api/user/get-other-comment-to-me')
}

// 获取回复评论区的内容
export const userGetReplyCommentToOtherService = () => {
  return request.get('api/user/get-reply-comment-to-other')
}

// 获取当前登录的用户信息
export const userGetUserinfoService = () => {
  return request.get('api/user/userinfo')
}

// 更新用户头像
export const userModifyUserImgService = (data) => {
  return request.post('api/user/modify-user-img', data)
}

// 更新用户信息
export const userModifyUserinfoService = (data) => {
  return request.post('api/user/modify-userinfo', data)
}

// 管理员账号获取用户所有信息接口
export const userSysUserinfoService = (params) => {
  return request.get('api/user/sys/userinfo', {
    params
  })
}

// 管理员修改用户信息
export const userSysUpdateService = (data) => {
  return request.post('api/user/sys/update', data)
}

/***************************************************************************/
// 忘记密码
export const userRestGetByUsernameService = (username) => {
  return request.get('api/user/rest/get-by-username', {
    params: {
      username
    }
  })
}

// 获取邮箱验证码
export const userRestGetEmailCodeService = (username, email) => {
  return request.get('api/user/rest/get-email-code', {
    params: {
      username,
      email
    }
  })
}

// 校验邮箱验证码
export const userRestVerifyEmailCodeService = (data) => {
  return request.post('api/user/rest/verify-email-code', data)
}

// 重置密码
export const userRestPwdService = (user, key) => {
  return request.post('api/user/rest/pwd', {
    user,
    key
  })
}

// 判断用户是否登录
export const userIsLogin = () => {
  return request.get('api/user/is-login')
}

/***************************************************************************/
